
$(function () {
    require([],function () {

        var $user = $(".user");
        var $pwd = $(".pwd");
        $(".btn").on("click",function () {
            var user = $user.val().trim();
            var pwd = $pwd.val().trim();
            if(!user){
                window.wxc.xcConfirm("用户名不能为空", window.wxc.xcConfirm.typeEnum.error);
            }else if(pwd.length < 6){
                window.wxc.xcConfirm("密码长度不能小于6", window.wxc.xcConfirm.typeEnum.error);
            }else{
                var url = '/api/login';
                if(!_app){
                    url = "/self/api/login"
                }
                $.ajax({
                    url:url,
                    type:"post",
                    data:{
                        name:user,
                        password:pwd,
                        _app:_app,
                        _cd:_cd
                    },
                    success:function (res) {
                        console.log(res);

                      window.location.href = res.data._url;
                    }
                });
            }

        });

    })
});